package revontuli.aMHD;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.util.Log;

/**
 * Trieda, ktora podla nastaveni urcuje, aka obrazovka sa ma ukazat pri spusteni
 * @author revontuli
 *
 */
public class LauncherAct extends Activity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
		
		String act = settings.getString("settings_startupact", "stopfinder");
		
		if (act.equals("stopfinder")) {
			startActivity(new Intent(getApplicationContext(), StopFinderAct.class));
		} else if (act.equals("stopmap")) {
			startActivity(new Intent(getApplicationContext(), StopMapAct.class));
		} else if (act.equals("stoplist")) {
			startActivity(new Intent(getApplicationContext(), StopListAct.class));
		} else if (act.equals("linelist")) {
			startActivity(new Intent(getApplicationContext(), LineListAct.class));
		} else if (act.equals("connfinder")) {
			startActivity(new Intent(getApplicationContext(), ConnFinderAct.class));
		}
		
		if (settings.getBoolean("settings_autoupdates", true) && !aMHDApp.mDataManager.getOffline()) {
			aMHDApp.mDataManager.updateAllData();
			Log.i(aMHDApp.TAG, "Auto-update started.");
		}

		finish();
	}
}
